package com.example.jetpacktest

import androidx.appcompat.app.AppCompatActivity

import android.os.Bundle
import android.view.View
import com.example.jetpacktest.databinding.DataBindingExampleActivity
import com.example.jetpacktest.lifecycle.LifeCycleExampleActivity
import com.example.jetpacktest.livedata.LiveDataExampleActivity
import com.example.jetpacktest.navigation.NavigationSampleActivity
import com.example.jetpacktest.room.RoomActivity
import com.example.jetpacktest.viewmodel.ViewModelExampleActivity
import kotlinx.android.synthetic.main.activity_main.*
import org.jetbrains.anko.startActivity

class MainActivity : AppCompatActivity(), View.OnClickListener {
    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.main_life_cycle -> {
                startActivity<LifeCycleExampleActivity>()
            }
            R.id.main_navigation -> {
                startActivity<NavigationSampleActivity>()
            }
            R.id.main_viewmodel -> {
                startActivity<ViewModelExampleActivity>()
            }
            R.id.main_livedata -> {
                startActivity<LiveDataExampleActivity>()
            }
            R.id.main_room -> {
                startActivity<RoomActivity>()
            }
            R.id.main_databinding -> {
                startActivity<DataBindingExampleActivity>()
            }
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        main_life_cycle?.setOnClickListener(this)
        main_navigation?.setOnClickListener(this)
        main_viewmodel?.setOnClickListener(this)
        main_livedata?.setOnClickListener(this)
        main_room?.setOnClickListener(this)
        main_databinding?.setOnClickListener(this)
    }
}
